package com.wang.config;

import org.apache.dubbo.config.RegistryConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

//@Configuration
public class NacosConfig {

    @Value("${dubbo.registry.address.local:}")
    private String registryAddressLocal;

    @Value("${dubbo.registry.address.online:}")
    private String registryAddressOnline;

    //@Primary
    @Bean
    public RegistryConfig registryConfigLocal() {
        RegistryConfig registryConfig = new RegistryConfig();
        registryConfig.setAddress(registryAddressLocal);
        return registryConfig;
    }

    //@Bean
    public RegistryConfig registryConfigOnline() {
        RegistryConfig registryConfig = new RegistryConfig();
        registryConfig.setAddress(registryAddressOnline);
        registryConfig.setUsername("nacos");
        registryConfig.setPassword("nacos");
        return registryConfig;
    }
}
